package com.pond.pond.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.pond.common.log.annotation.Log;
import com.pond.common.log.enums.BusinessType;
import com.pond.common.security.annotation.RequiresPermissions;
import com.pond.pond.domain.FacilityType;
import com.pond.pond.service.IFacilityTypeService;
import com.pond.common.core.web.controller.BaseController;
import com.pond.common.core.web.domain.AjaxResult;
import com.pond.common.core.utils.poi.ExcelUtil;
import com.pond.common.core.web.page.TableDataInfo;

/**
 * 设施字典Controller
 * 
 * @author ruoyi
 * @date 2025-07-15
 */
@RestController
@RequestMapping("/facilityType")
public class FacilityTypeController extends BaseController
{
    @Autowired
    private IFacilityTypeService facilityTypeService;

    /**
     * 查询设施字典列表
     */
    @RequiresPermissions("pond:facilityType:list")
    @GetMapping("/list")
    public TableDataInfo list(FacilityType facilityType)
    {
        startPage();
        List<FacilityType> list = facilityTypeService.selectFacilityTypeList(facilityType);
        return getDataTable(list);
    }

    /**
     * 导出设施字典列表
     */
    @RequiresPermissions("pond:facilityType:export")
    @Log(title = "设施字典", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FacilityType facilityType)
    {
        List<FacilityType> list = facilityTypeService.selectFacilityTypeList(facilityType);
        ExcelUtil<FacilityType> util = new ExcelUtil<FacilityType>(FacilityType.class);
        util.exportExcel(response, list, "设施字典数据");
    }

    /**
     * 获取设施字典详细信息
     */
    @RequiresPermissions("pond:facilityType:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(facilityTypeService.selectFacilityTypeById(id));
    }

    /**
     * 新增设施字典
     */
    @RequiresPermissions("pond:facilityType:add")
    @Log(title = "设施字典", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FacilityType facilityType)
    {
        return toAjax(facilityTypeService.insertFacilityType(facilityType));
    }

    /**
     * 修改设施字典
     */
    @RequiresPermissions("pond:facilityType:edit")
    @Log(title = "设施字典", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FacilityType facilityType)
    {
        return toAjax(facilityTypeService.updateFacilityType(facilityType));
    }

    /**
     * 删除设施字典
     */
    @RequiresPermissions("pond:facilityType:remove")
    @Log(title = "设施字典", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(facilityTypeService.deleteFacilityTypeByIds(ids));
    }
}
